package yto.freemarker.springaop.cglib;


import org.springframework.cglib.proxy.MethodInterceptor;
import org.springframework.cglib.proxy.MethodProxy;

import java.lang.reflect.Method;

/**
 * @author dongxing
 **/
public class MyMethodInterceptor implements MethodInterceptor {

    //参数1：代理对象
    //参数2：目标对象的方法对象
    //参数3：目标对象的方法的参数的值
    //参数4：代理对象的方法对象
    @Override
    public Object intercept(Object o, Method method, Object[] objects, MethodProxy methodProxy) throws Throwable {
        System.out.println("intercept cglib");
        //调用目标的方法
        Object o1 = methodProxy.invokeSuper(o, objects);
        return o1;
    }
}
